package me.ingxin.android.sample.lego.interceptor

import android.content.Context
import me.ingxin.android.router.annotaions.Interceptor
import me.ingxin.android.router.route.RouteInterceptor
import me.ingxin.android.router.route.Request
import me.ingxin.android.sample.lego.utils.logD

/**
 * Created by ingxin on 2022/4/27
 * 拦截所有路由并追加参数
 */
@Interceptor("appGlobal1", global = true, priority = 3)
class Global1Interceptor : RouteInterceptor {
    override fun handle(context: Context, request: Request, dispatcher: RouteInterceptor.Dispatcher) {
        "Global1Interceptor开始执行".logD()
        request.putString("ext1", "拦截器Global1Interceptor追加的字段")
        //不拦截，
        dispatcher.continueRun()

        //拦截
//        dispatcher.interrupt()

    }
}